<template>
  <div class="auth-wrapper">
    <div class="top">
      <div class="title">权限管理</div>
      <el-button @click="$router.push({path: '/auth/add-auth'})">添加</el-button>
    </div>
    <div class="bottom">
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="name" label="员工姓名" width="180" />
        <el-table-column prop="phone" label="手机号" width="180" />
        <el-table-column prop="job" label="职位" />
        <el-table-column prop="account" label="账号" />
        <el-table-column prop="address" label="操作"  fixed="right" width="180" align="center">
          <template slot-scope="scope">
            <div>
              <span class="col-blue" @click="$router.push({path: '/auth/add-auth', query: {id: scope.row.id}})">编辑</span>
              <span class="col-red" @click="delAccount(scope.row)">删除</span>
            </div>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
import { getOperator, delAccount } from '@/api/http/account'
export default {
  data() {
    return {
      tableData: []
    }
  },
  created() {
    this.getOperator()
  },
  methods: {
    // 获取权限列表
    getOperator() {
      getOperator().then(res => {
        if (res.code == 200) {
          this.tableData = res.data.list
        }
      })
    },
    // 删除账号
    delAccount(row) {
      delAccount({ admin_id: row.id }).then(res => {
        if ((res.code = 200)) {
          this.$message.success('删除成功')
          this.getOperator()
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
@import "@/styles/el-button.scss";
@import "@/styles/el-table.scss";
@import "@/styles/color.scss";
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .title {
    line-height: 40px;
    color: rgba(68, 68, 68, 1);
    font-size: 18px;
    text-align: left;
    font-family: Roboto;
    font-weight: bold;
  }
}
</style>
